object DesignChangeController extends Controller{
val Home = Redirect(routes.DesignChangeController.list(0,""))
+ val Home2 = Redirect(routes.PartsListController.index(0,0,""))
val designChangeRegistForm = Form(
mapping(
Redirect(routes.DesignChangeController.designChangeCoverModify(id, 0, ""))
}
}
+
+ def designChangeCancelByLine(designChangeId: Long, delParentName: String, delChildName: String, addParentName: String, addChildName: String) = Action {
+ inTransaction {
+ val designChange = DesignChangeManager().getById(designChangeId)
+ if(!delParentName.isEmpty()) {
+ val delParent = PartManager().getByName(delParentName)
+ val delChild = PartManager().getByName(delChildName)
+ val cancelDelRelation = designChange.delPartRelation.where(pr => pr.parentId === delParent.id and pr.childId === delChild.id).head
+ DesignChangeManager().designChangeDelCancelBySeq(designChangeId, cancelDelRelation.dcSeq)
+ }
+ if(!addParentName.isEmpty()) {
+ val addParent = PartManager().getByName(addParentName)
+ val addChild = PartManager().getByName(addChildName)
+ val cancelAddRelation = designChange.addPartRelation.where(pr => pr.parentId === addParent.id and pr.childId === addChild.id).head
+ DesignChangeManager().designChangeAddCancelBySeq(designChangeId, cancelAddRelation.dcSeq)
+ }
+ }
+ Redirect(routes.DesignChangeController.designChangeCoverModify(designChangeId, 0, ""))
+ }
+
+ def designChangeForm(parentName:String, childName:String) = Action { implicit request =>
+ inTransaction {
+ var designChangeRelationForm = DesignChangeRelationForm(null, null, "")
+ // 設計変更追加の場合、変更前の上位品番はセットしない。
+ if(childName.isEmpty()) {
+ designChangeRelationForm = DesignChangeRelationForm(generatePartsListBean("", childName), generatePartsListBean(parentName, childName), "")
+ } else {
+ designChangeRelationForm = DesignChangeRelationForm(generatePartsListBean(parentName, childName), generatePartsListBean(parentName, childName), "")
+ }
+ Ok(views.html.designChangeRelationForm(designChangeRelationRegistForm.fill(designChangeRelationForm), ""))
+ }
+ }
+
+ def designChange() = Action { implicit request =>
+ designChangeRelationRegistForm.bindFromRequest.fold(
+ formWithErrors => BadRequest(views.html.designChangeRelationForm(formWithErrors, "")),
+ data => {
+ inTransaction {
+ val message = Check().loopCheckDc(data)
+ if(message == null) {
+ DesignChangeManager().designChange(data)
+ Home2.flashing("success" -> "Relation %s has been changed".format(data.partsListBeanBefore.parent + "/" + data.partsListBeanBefore.child))
+ } else {
+ Ok(views.html.designChangeRelationForm(designChangeRelationRegistForm.fill(data), Messages(message)))
+ }
+ }
+ }
+ )
+ }
def designChangeAppend(designChangeId: Long, dcSeq: Long, targetParentName: String) = Action {
inTransaction {
)(PartsListBean.apply)(PartsListBean.unapply)
)
- val designChangeRegistForm = Form(
- mapping(
- "partsListBeanBefore" -> mapping(
- "parent" -> text,
- "child" -> text,
- "quantity" -> longNumber
- )(PartsListBean.apply)(PartsListBean.unapply),
- "partsListBeanAfter" -> mapping(
- "parent" -> nonEmptyText,
- "child" -> text,
- "quantity" -> longNumber
- )(PartsListBean.apply)(PartsListBean.unapply),
- "dcno" -> nonEmptyText
- )(DesignChangeRelationForm.apply)(DesignChangeRelationForm.unapply)
- )
-
def index(opt:Int, page:Int, key:String) = Action { implicit request =>
var partBuffer = ArrayBuffer[PartsListBean]()
inTransaction {
}
}
- def designChangeForm(parentName:String, childName:String) = Action { implicit request =>
- inTransaction {
- var designChangeRelationForm = DesignChangeRelationForm(null, null, "")
- // 設計変更追加の場合、変更前の上位品番はセットしない。
- if(childName.isEmpty()) {
- designChangeRelationForm = DesignChangeRelationForm(generatePartsListBean("", childName), generatePartsListBean(parentName, childName), "")
- } else {
- designChangeRelationForm = DesignChangeRelationForm(generatePartsListBean(parentName, childName), generatePartsListBean(parentName, childName), "")
- }
- Ok(views.html.designChangeRelationForm(designChangeRegistForm.fill(designChangeRelationForm), ""))
- }
- }
-
- def designChange() = Action { implicit request =>
- designChangeRegistForm.bindFromRequest.fold(
- formWithErrors => BadRequest(views.html.designChangeRelationForm(formWithErrors, "")),
- data => {
- inTransaction {
- val message = Check().loopCheckDc(data)
- if(message == null) {
- DesignChangeManager().designChange(data)
- Home.flashing("success" -> "Relation %s has been changed".format(data.partsListBeanBefore.parent + "/" + data.partsListBeanBefore.child))
- } else {
- Ok(views.html.designChangeRelationForm(designChangeRegistForm.fill(data), Messages(message)))
- }
- }
- }
- )
- }
-
def generatePartsListBean(parentNo:String, childNo:String):PartsListBean = {
if(childNo.isEmpty()) {
PartsListBean(parentNo, childNo, 0)
return designChangeBuffer
}
- def designChangeCancel(id: Long) ={
+ def designChangeCancel(id: Long) = {
val cancelDesignChange = getById(id)
for (cancelAddRelation <- cancelDesignChange.addPartRelation) {
cancelAddRelation.parent.head.parts.dissociate(cancelAddRelation.child.head)
PartsListDb.partRelations.update(cancelDelRelation)
}
}
+
+ def designChangeAddCancelBySeq(designChangeId: Long, dcSeq: Long) = {
+ val designChange = getById(designChangeId)
+ val cancelAddRelation = designChange.addPartRelation.where(pr => pr.dcSeq === dcSeq).head
+ cancelAddRelation.parent.head.parts.dissociate(cancelAddRelation.child.head)
+ }
+
+ def designChangeDelCancelBySeq(designChangeId: Long, dcSeq: Long) = {
+ val designChange = getById(designChangeId)
+ val cancelDelRelation = designChange.delPartRelation.where(pr => pr.dcSeq === dcSeq).head
+ cancelDelRelation.delDcId = 0L
+ cancelDelRelation.dcSeq = 0L
+ PartsListDb.partRelations.update(cancelDelRelation)
+ }
def designChangeUpdate(data: DesignChangeRelationForm, partName: String) = {
val dc = getByName(data.dcno)
val updateRelation = dc.addPartRelation.where(pr => pr.parentId === parent.id and
pr.childId === cancelChild.id).head
val dcSeq = updateRelation.dcSeq
- PartsListDb.partRelations.deleteWhere(pr => pr.addDcId === dc.id and pr.dcSeq === dcSeq)
+ updateRelation.parent.head.parts.dissociate(updateRelation.child.head)
relationAdd(parent.name, child.name, data.partsListBeanAfter.quantity, dc, dcSeq)
}
}
@main("Design Change by Play 2.1") {
<h1>@Messages("title21")</h1>
@error
- @form(routes.PartsListController.designChange()) {
+ @form(routes.DesignChangeController.designChange()) {
@commonDesignChangeRelationForm(designChangeRelationForm)
}
<br />
<th>@Messages("form.header11")@Messages("list.header1")</th>
<th>@Messages("form.header11")@Messages("list.header2")</th>
<th>@Messages("form.header11")@Messages("list.header3")</th>
+ <th></th>
</tr>
</thead>
<tbody>
<a href="/designChangeModify?designChangeId=@id&dcDelSeq=@delRelation.dcSeqBefore&dcAddSeq=@delRelation.dcSeqAfter&message=">@delRelation.quantityAfter</a>
}
</td>
+ <td><a href="/designChangeCancelByLine?designChangeId=@id&delParent=@delRelation.parentBefore&delChild=@delRelation.childBefore&addParent=@delRelation.parentAfter&addChild=@delRelation.childAfter">@Messages("list.link14")</a></td>
</tr>
}
</tbody>
POST /relationSave controllers.PartsListController.relationRegistration
GET /relationUpdate controllers.PartsListController.updateRelation(parent:String, child:String)
POST /relationChange controllers.PartsListController.relationUpdate(childName:String)
-GET /designChangeForm controllers.PartsListController.designChangeForm(parentName, childName)
-POST /designChange controllers.PartsListController.designChange
GET /designChangeCoverForm controllers.DesignChangeController.create
POST /designChangeCover controllers.DesignChangeController.designChangeCoverRegistration
GET /designChangeCoverModify controllers.DesignChangeController.designChangeCoverModify(designChangeId:Long, dcSeq:Long, message:String)
POST /designChangeCoverModification controllers.DesignChangeController.designChangeCoverModification(id: Long)
+GET /designChangeForm controllers.DesignChangeController.designChangeForm(parentName, childName)
+POST /designChange controllers.DesignChangeController.designChange
POST /designChangeCancel controllers.DesignChangeController.designChangeCancel(id:Long)
+GET /designChangeCancelByLine controllers.DesignChangeController.designChangeCancelByLine(designChangeId:Long, delParent:String, delChild:String, addParent:String, addChild:String)
GET /designChangeAppend controllers.DesignChangeController.designChangeAppend(designChangeId:Long, dcSeq:Long, parentName:String)
GET /designChangeModify controllers.DesignChangeController.designChangeRealtionModify(designChangeId: Long, dcDelSeq: Long, dcAddSeq: Long)
POST /designChangeModification controllers.DesignChangeController.designChangeRelationModification(partName: String)